package com.hdl.servlet;

import com.hdl.request.Request;
import com.hdl.response.Response;

/**
 * 类名 HttpServlet
 * 描述 HttpServlet抽象类
 *
 * @author hedonglin
 * @version 1.0
 * @date 2020/5/31 16:59
 */
public abstract class HttpServlet implements Servlet {
    @Override
    public void init() throws Exception {

    }

    @Override
    public void destroy() throws Exception {

    }

    /** 处理get请求 */
    public abstract void doGet(Request request, Response response);

    /** 处理post请求 */
    public abstract void doPost(Request request,Response response);

    @Override
    public void service(Request request, Response response) throws Exception {
        if("GET".equalsIgnoreCase(request.getMethod())) {
            doGet(request,response);
        }else{
            doPost(request,response);
        }
    }
}
